home *** CD-ROM | disk | FTP | other *** search
- ────────────────────────────────────────────────────────────────────────────────
- ; this program looks for a specified string in all sectors of a partition
- ; i used the program to locate a source of an important program that was
- ; lost due to a harddisk crash that destroyed my fat tables ...
- ; learn from it...it's easy - plasmoid/deep/thc
- ────────────────────────────────────────────────────────────────────────────────
- .model small
- .stack 100h
- .386
- .code
- sector_start equ 0
- sector_stop equ 10235
- jmp main
- ────────────────────────────────────────────────────────────────────────────────
- searchstring proc near
- mov cx,0
- searchloop: mov di,offset string
- mov si,offset buffer
- add si,cx
- mov stringfound,0
- stringloop: mov al,[di]
- cmp al,0
- je endsearch
- cmp al,[si]
- je found
- mov stringfound,-1
- found: inc di
- inc si
- jmp stringloop
- endsearch: inc cx
- cmp stringfound,0
- je success
- cmp cx,512
- jb searchloop
- success: ret
- searchstring endp
- ────────────────────────────────────────────────────────────────────────────────
- writetofile proc near
- mov ah,40h ; write to file the buffer
- mov bx,handle
- mov cx,512
- mov dx,offset buffer
- int 21h
- ret
- writetofile endp
- ────────────────────────────────────────────────────────────────────────────────
- openfile proc near
- mov dx,offset rescuefile
- mov ah,3ch ; create file
- mov cx,00
- int 21h
- mov ah,3dh ; open file for write
- mov al,01
- int 21h
- mov handle,ax
- ret
- openfile endp
- ────────────────────────────────────────────────────────────────────────────────
- closefile proc near
- mov bx,handle
- mov ah,3eh
- int 21h
- ret
- closefile endp
- ────────────────────────────────────────────────────────────────────────────────
- readsector proc near
- mov bp,sp ; save stack
- mov al,3 ; 3 - drive: D
- mov cx,1 ; 1 - one sector only
- mov dx,sector_number
- mov bx,offset buffer
- int 25h
- mov sp,bp ; restore stack
- ret
- readsector endp
- ────────────────────────────────────────────────────────────────────────────────
- main: push @data
- pop ds
- call openfile
-
- mainloop: call readsector
- call searchstring
- cmp stringfound,-1
- je notfound
- call writetofile
- notfound: inc sector_number
- cmp sector_number,sector_stop+1
- jb mainloop
-
- call closefile
- mov ax,4c00h
- int 21h
-
- ────────────────────────────────────────────────────────────────────────────────
- .data
- stringfound db -1
- handle dw 0
- rescuefile db 'rescue.lst',0
- sector_number dw sector_start
- buffer db 512 dup (0)
- string db ');',0dh,0ah,0
- ────────────────────────────────────────────────────────────────────────────────
- end